package com.aeoj.clientmanagement.domain.problem.vo;

import com.aeoj.clientmanagement.domain.problem.Problem;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serial;
import java.io.Serializable;
import java.util.Date;

/**
 * author: ZSM
 * time: 2025-04-14 22:31
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class ProblemVO implements Serializable {
    @Serial
    private static final long serialVersionUID = 1L;

    private Long id;

    private String title;

    private String content;

    private String tags;

    private Integer difficulty;

    private String hints;

    private Integer timeLimit;

    private Integer memoryLimit;

    private Integer submissionCount;

    private Integer acceptedCount;

    private Integer likes;

    private Integer favorites;

    private Date createTime;

    private String author;

    public static ProblemVO toProblemVO(Problem problem) {
        if (problem == null) {
            return null;
        }
        return ProblemVO.builder()
                .id(problem.getId())
                .title(problem.getTitle())
                .content(problem.getContent())
                .tags(problem.getTags())
                .difficulty(problem.getDifficulty())
                .hints(problem.getHints())
                .timeLimit(problem.getTimeLimit())
                .memoryLimit(problem.getMemoryLimit())
                .submissionCount(problem.getSubmissionCount())
                .acceptedCount(problem.getAcceptedCount())
                .likes(problem.getLikes())
                .favorites(problem.getFavorites())
                .createTime(problem.getCreateTime())
                .build();
    }

    public Problem toProblem() {
        return Problem.builder()
                .id(this.getId())
                .title(this.getTitle())
                .content(this.getContent())
                .tags(this.getTags())
                .difficulty(this.getDifficulty())
                .hints(this.getHints())
                .timeLimit(this.getTimeLimit())
                .memoryLimit(this.getMemoryLimit())
                .submissionCount(this.getSubmissionCount())
                .acceptedCount(this.getAcceptedCount())
                .likes(this.getLikes())
                .favorites(this.getFavorites())
                .createTime(this.getCreateTime())
                .build();
    }

}
